package com.yzd.learnjava.enumerated;

import com.yzd.learnjava.util.Enums;
import com.yzd.learnjava.util.Print;

public enum SecurityCategory {
	Stock(Security.Stock.class),
	BOND(Security.Bond.class);
	
	interface Security{
		enum Stock implements Security{
			SHORT, LONG, MARGING
		} 
		
		enum Bond implements Security{
			MUNICIPAL, JUNK
		}
	}
	Security[] values;
	SecurityCategory(Class<? extends Security> kind){
		values = kind.getEnumConstants();
	}
	
	public Security randomSelection() {
		return Enums.random(values);
	}
	
	
	public static void main(String[] args) {
		for(int i = 0 ; i < 10; i++) {
			SecurityCategory category = Enums.random(SecurityCategory.class);
			Print.print(category + ": " + category.randomSelection());
		}
	}
}


